﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace PeAutoControl
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            // 构建配置
            var configuration = new ConfigurationBuilder()
                .SetBasePath(AppContext.BaseDirectory)
                .AddJsonFile("config.json", optional: false, reloadOnChange: true)
                .Build();

            var appSettings = configuration.GetSection("AppSettings").Get<config>();

            // 构建日志
            var loggerFactory = LoggerFactory.Create(loggingBuilder =>
            {
                loggingBuilder.SetMinimumLevel(LogLevel.Debug);
                loggingBuilder.AddConsole();
            });
            ILogger serverLogger = loggerFactory.CreateLogger("Server");

            // 构建Modbus服务
            Modbus.Start(serverLogger);

            Console.ReadKey();
        }
    }
}